#ifndef TEMPLATEWIDGET_H
#define TEMPLATEWIDGET_H

#include <QDebug>
#include <QObject>
#include <QWidget>
#include <QVBoxLayout>
#include <QProcess>
#include <QtDBus>
#include <QStyleOption>
#include <QPushButton>

#include "../gsettingmanager.h"
#include "../dbusmanager.h"
#include "../commondata.h"
#include "../dataprocess.h"

#define POWERSAVING_NAME                "powersaving"
#define BLUETOOTH_NAME                  "bluetooth"
#define FLIGHTMODE_NAME                 "flightmode"
#define PROJECTSCREEN_NAME              "projectionscreen"
#define EYE_PROTECTION_NAME             "EyeProtection"
#define SCREENSHOT_NAME                 "screenshot"
#define CLOCK_NAME                      "clock"
#define SETTING_NAME                    "setting"
#define CLIPBOARD_NAME                  "clipboard"
#define NOTEBOOK_NAME                   "notebook"
#define SUPPORT_NAME                    "kylinServiceSupport"
#define NODISTURB_NAME                  "nodisturb"
#define ROTATION_NAME                   "automaticRotation"
#define PAD_NAME                        "padWidget"

#define KYLIN_SETTING_PRESS_3_1_NAME        "applications-system-symbolic"
#define KYLIN_SETTING_NORMAL_PATH       ":/image/pad_control.svg"
#define KYLIN_SETTING_PRESS_PATH        ":/image/pad_controlopen.svg"

#define KYLIN_POWER_NORMAL_NAME      "ukui-eco-symbolic"
#define KYLIN_POWER_PRESS_NAME       "pad_poweropen"
#define KYLIN_POWER_NORMAL_PATH      ":/image/pad_power.svg"
#define KYLIN_POWER_PRESS_PATH       ":/image/pad_poweropen.svg"

#define KYLIN_BLUETOOTH_NORMAL_PATH      "bluetooth-symbolic"
#define KYLIN_BLUETOOTH_PRESS_PATH       ":/image/bluetooth.svg"

#define KYLIN_SETTING_WHITE_PATH       ":/image_major/icon-flightmode-white.svg"
#define KYLIN_SETTING_BLACK_PATH       ":/image_major/icon-flightmode-black.svg"

#define KYLIN_FLIGHTMODE               "ukui-airplane-mode-on-symbolic"

#define KYLIN_SETTING_SCREEN_WHITE_PATH       ":/image_major/icon-projection-white.svg"
#define KYLIN_SETTING_SCREEN_BLACK_PATH       ":/image_major/icon-projection-black.svg"

#define KYLIN_SETTING_SCREEN            "ukui-projection-symbolic"

#define KYLIN_EYE_MODE_NORMAL_3_1_NAME     "ukui-nightmode-symbolic"
#define KYLIN_EYE_MODE_NORMAL_INTEL_NAME   ":/image/pad_eyes.svg"
#define KYLIN_EYE_MODE_OPEN_INTEL_NAME     ":/image/pad_eyesopen.svg"

#define KYLIN_SCREENSHOT_NORMAL_NAME    "kylin-screenshot-normal"
#define KYLIN_SCREENSHOT_HOVER_NAME     "kylin-screenshot-hover"
#define KYLIN_SCREENSHOT_PRESS_NAME     "kylin-screenshot-pressed"

#define KYLIN_SCREENSHOT_NORMAL_PATH_3_1_WHITE       "ukui-screenshot-symbolic"
#define KYLIN_SCREENSHOT_NORMAL_PATH_INTEL_WHITE     ":/image/ic-screenshot-white.svg"
#define KYLIN_SCREENSHOT_NORMAL_PATH_INTEL_BLACK     ":/image/ic-screenshot.svg"

#define KYLIN_CLIPBOARD_WHITE_PATH       ":/image_major/icon-clipboard-white.svg"
#define KYLIN_CLIPBOARD_BLACK_PATH       ":/image_major/icon-clipboard-black.svg"

#define KYLIN_NODISTURB_NORMAL_NAME                 "pad_Donotdisturb"
#define KYLIN_NODISTURB_PRESS_NAME                  "pad_Donotdisturbopen"

#define KYLIN_NODISTURB_NORMAL_PATH                 ":/image/pad_Donotdisturb.svg"
#define KYLIN_NODISTURB_PRESS_PATH                  ":/image/pad_Donotdisturbopen.svg"


#define KYLIN_AUTOMATICROTATION_NORMAL_NAME     "pad_autorotation"
#define KYLIN_AUTOMATICROTATION_PRESS_NAME      "pad_autorotationopen"

#define KYLIN_AUTOMATICROTATION_NORMAL_PATH     ":/image/pad_autorotation.svg"
#define KYLIN_AUTOMATICROTATION_PRESS_PATH      ":/image/pad_autorotationopen.svg"

#define KYLIN_PAD_NORMAL_NAME           "pad_pad"
#define KYLIN_PAD_PRESS_NAME            "pad_padopen"

#define KYLIN_PAD_NORMAL_PATH           ":/image/pad_pad.svg"
#define KYLIN_PAD_PRESS_PATH            ":/image/pad_padopen.svg"

#define KYLIN_NOTEBOOK_PATH                   "ukui-notes-symbolic"
#define KYLIN_SUPPORT_PATH                    "ukui-service-support-symbolic"
#define KYLIN_CLOCK_PATH                      "alarm-symbolic"

#define CLICK "click"

class templatewidget : public QWidget
{
    Q_OBJECT
public:
    explicit templatewidget(QString buttonName);
    ~templatewidget();

private:
    QString m_pButtonName;

    QWidget*            m_pWidgetButton;
    QPushButton*        m_pInteriorButton;
    QLabel*             m_pInteriorLabel;

    QVBoxLayout*        m_pVboxButtonLayout;
    QVBoxLayout*        m_pVboxMainLayout;

    void initInterfaceAttribute();
    void initInterfaceLayout();
    void initGsettingConnect();

    bool checkButtonValid();
    void setButtonIcon(bool state);
    void setButtonStyle(bool state);
    void initButtonConnect();
    void setLabelText();
    void changeStyle(bool state);
    bool getBacklitFile();
    void getInitialData();

    bool oneShotBool = true;
    LabelFotmatText *m_pLabelFotmatText;

    QColor getSystemPaleteColor(bool state);

    int m_brightness = 0;
    int m_AcPowerStatus = 0;
    int m_BatteryPowerStatus = 0;

private slots:
    void setButtonStatus();
    void setLabelTextColor(bool state);
    void settingButtonClick();
    void powerSavingButtonClickSlots();
    void bluetoothButtonClickSlots();
    void flightmodeClickSlots();
    void projectionscreenClickSlots();
    void eyeProtectionClickSlots();
    void screenshotClickSlots();
    void clipboardClickSlots();
    void nodisturbClickSlots();
    void automaticRotationClickSlots();
    void automaticRotationButttonClickSlots();
    void padClickSlots();
    void noteBookClickSlots();
    void supportSlots();
    void clockSlots();

    void sendPointData(QString btnName);

};

#endif // TEMPLATEWIDGET_H
